<?php 
	require_once 'util/public.php';
	session_start();
	$islogin = FALSE;
	if(isset($_SESSION['login_user'])){
		$islogin = TRUE;
}?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>公司介绍</title>
<link rel="stylesheet" href="./style/default.css" type="text/css" />
<link rel="stylesheet" href="./style/post.css" type="text/css" />

<style type="text/css">
.page_link{
	text-decoration: underline;
	font-color: blue;
}

.sayer{
	color: #77f;
	margin-top: 0px;
}

.com_list{
	margin: 0px;
	list-style-image: url(images/msg.png);
	padding-left: 30px;
}

.comment{
	border: 1px solid #DDD;
	margin: 10px 0px 10px 0px;
	padding: 0px 5px 10px 10px;
}

.chking_comment{
	border: 1px solid #DDD;
	margin: 10px 0px 10px 0px;
	padding: 0px 5px 10px 10px;
}



.says{
	font-weight: bold;
}

.chking_text{
	font-style: italic;
	color: #555;
	font-weight: bold;
}

</style>

</head>
<body>

<?php 
	// 数据库操作
	require_once 'util/dbconnection.php';
	
  	$page_id = $_GET['page'];
  	if( !isset($page_id) ){
  		$page_id = 1;  // 默认第一页
  	}
  	
  	connect_db();
  	// 总行数
  	$all_count = get_fdbak_count();
  	// 每页的记录数
  	$page_count = 10;
  	// 取本页数据
  	$fb_list = array();
  	if( $all_count != 0 ){
  		$fb_list = get_feedback( ($page_id-1)*10, $page_count, '' );
  	}
  	
  	// 查找审核中的评论列表
  	// 取cookie
  	$cookie_author = $_COOKIE['feedback_author'];
  	$chking_fbs = array();
  	$maxc = -1;
  	$chking_fbs = get_feedback(0, $maxc, $cookie_author, 2);
  	$cookie_email =  $_COOKIE['feedback_contact_email'];
  	$cookie_phone =  $_COOKIE['feedback_contact_phone'];
  	
  	// 关闭数据库
	close_db();
?>

  <div id="page_header">
  </div>
  <div id="nav_line">
    <ul id="nav_list">
          <li>
              <a href="index.php">网站首页</a>
          </li>
          <li>
              <a href="intro.php">公司介绍</a>
          </li>
          <li>
              <a href="pic_show.php">图片展示</a>
          </li>
          <li>
              <a href="knowledge.php">花卉知识</a>
          </li>
          <li>
              <a href="contact.php">业务联系</a>
          </li>
          <li class="active">
              <a href="feedback.php">客户留言</a>
          </li>
          
    </ul>
  </div>
  
  <div class="body_content">
  <div class="intro_content">
	<div class="left">
	  <h1>客户留言</h1>
	    （给我们留言）
	  <ul>
	  	<li><a href="#">客户留言</a></li>
	  	<li><a href="#">给我们留言</a></li>
	  </ul>
	</div>
	<div class="right">
	    <h1>客户留言</h1>
	    <?php 
	    	echo '<p class="p_little">';
	    	echo "第".$page_id."页   共".ceil($all_count/10)."页";
	    	echo '</p>';
	    	// 本页留言内容
	    	echo '<ol class="com_list">';
	    	for( $i=0; $i<count($fb_list); $i++ ){
	    		$msg = $fb_list[$i];
	    		$atime = explode(' ', $msg['msg_date']);
	    		echo '<li class="comment">';
	    		echo '<p class="sayer"><span class="says">'.$msg['msger_name'].' 说:</span><br>'.$atime[0].' @ '.$atime[1].'</p>';
	    		echo '<p>'.nl2br($msg['msg_content']).'</p>';
	    		echo '</li>';
	    	}
	    	echo '</ol>';
	    	echo '<p class="p_little">';
	    	echo "分页跳转:";
	    	for( $i=1; $i<=ceil($all_count/10); $i++ ){
	    		if( $i == $page_id )
	    			echo "&nbsp;$i&nbsp;";
	    		else
	    			echo '<a class="page_link" href="feedback.php?page='.$i.'">&nbsp;'.$i."&nbsp;</a>";
	    	}
	    	
	    	// 本人提交的待审核的评论
	    	if( count($chking_fbs) != 0 ){
		    	echo '<ol class="chking_com_list">';
		    	for( $i=count($chking_fbs)-1; $i>=0; $i-- ){
		    		$msg = $chking_fbs[$i];
		    		$atime = explode(' ', $msg['msg_date']);
		    		echo '<li class="chking_comment">';
		    		echo '<p><span>'.$msg['msger_name'].' 说:</span><br><span class="chking_text">您的留言正在审核中...</span><br />'.$atime[0].' @ '.$atime[1].'</p>';
		    		echo '<p>'.nl2br($msg['msg_content']).'</p>';
		    		echo '</li>';
		    	}
		    	echo '</ol>';
	    	}
	    ?>
	    
	  	<h1>给我们留言</h1>
	  	<p class="p_little"></p>
	  	<form action="feedback-commit.php" method="post" id="feedbackform">
		  <p>
			<label for="author"><small>您的姓名</small></label>
			<input type="text" name="author" id="author" value="<?php echo $cookie_author;?>" size="22" tabindex="1" />
			<font color="red">*</font>
		  </p>
		  <p>
		  	<label for="email"><small>您的联系方式 <font color="red">*</font> (必填一项)</small></label>
		  </p>
	      <p>
	      	<label for="email"><small>您的邮箱</small></label>
	        <input type="text" name="email" id="email" value="<?php echo $cookie_email;?>" size="22" tabindex="2" />
			<label for="email"><small>(不会被公开)</small></label>
		  </p>
		  <p>
	      	<label for="phone"><small>您的电话</small></label>
	        <input type="text" name="phone" id="phone" value="<?php echo $cookie_phone;?>" size="22" tabindex="2" />
			<label for="phone"><small>(不会被公开)</small></label>
		  </p>
		  <p>
	      	<label for="other"><small>其他方式</small></label>
	        <input type="text" name="other" id="other" value="" size="40" tabindex="3" />
			<label for="other"><small>QQ、MSN等 (不会被公开)</small></label>
		  </p>
		  <p>
		    <textarea name="content" id="content" cols="58" rows="10" tabindex="4"></textarea>
		    <label for="content"><small><font color="red">*</font></small></label>
		  </p>
		<p>
		<?php 
			
			$backurl = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
			echo '<input type="hidden" id="backurl" name="backurl" value="'.$backurl.'" >';
		?>
		  <input name="submit" type="submit" id="submit" tabindex="5" value="提交" />
		</p>

</form>
	</div>
  </div>
  </div>

  <?php echo_footer($islogin)
  ?>

</body>
</html>
